#ifndef __HF_RINGBUFFER_H__
#define __HF_RINGBUFFER_H__

#include "hf_core_common.h"

struct hf_ringbuf
{
	volatile uint32_t read_index;  /* 当前读位置 */
	volatile uint32_t write_index; /* 当前写位置 */
	uint32_t buffer_size;		   /* ringbuffer大小 */
	uint8_t *buffer_ptr;		   /* 指向ringbuffer */
};

void hf_ringbuf_init(struct hf_ringbuf *ring, uint8_t *pool, uint32_t size);

int8_t hf_ringbuf_write(struct hf_ringbuf *ring, uint8_t ch);

int8_t hf_ringbuf_read(struct hf_ringbuf *ring, uint8_t *ch);

int8_t hf_ringbuf_clean(struct hf_ringbuf *ring);

uint32_t hf_ringbuf_get_used_size(struct hf_ringbuf *ring);

uint32_t hf_ringbuf_get_free_size(struct hf_ringbuf *ring);


#endif /* __HF_RINGBUFFER_H__ */